<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"> 
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>捷豹英仕挑战赛</title> 
    <link rel="stylesheet" href="/Public/Home/css/font.css" />
    <link rel="stylesheet" href="/Public/Home/css/upimg.css" />
    <script type="text/javascript" src="/Public/Home/js/jquery.min.js"></script> 
	<script src="/Public/Home/js/adaptUILayout.js"></script> 
	<script language="javascript">
		adaptUILayout.adapt(640);
	</script>
</head>
<body> 
<div id="body">
	<div id="bg"></div> 
	<div id="upimgh2">秀出您眼中的捷豹英仕锋尚</div>
	<div id="img_box">
		<div id="img_back"></div>
		<div id="img_view" <if condition="$img">  style="background-image: url({$img})" </if>></div>
		<div id="img_front"><input id="upfile" type="file" /></div>
		<p style=" text-align: center; margin-top: 70%; color: #FFF; font-size: 24px;">请点击上方相框进入手机相册选择照片</p>
	</div>
	<div id="operBtnbox">
		<div id="upBtn">上传照片</div>
		<div id="backBtn">返回首页</div>
	</div>
</div>

<script language="javascript">
var dat = '';
var url = '/Home/Jaguar/doupimg';



$(function(){
	$('#body').on('touchstart',function(){
		
	});
	$('#upfile').change(function(e){ 
		var reader = new FileReader();
	    reader.onload = function(e) {
			   dat = e.target.result;
	           $('#img_view').css('background-image','url('+ dat  +')'); 
		}
		reader.readAsDataURL(document.getElementById("upfile").files[0]);
		return false; 
	});
	
	$('#upBtn').click(function(){
		var xhr = new XMLHttpRequest(),
		fromData = new FormData();
		fromData.append("imgdata", dat);
		xhr.open("post",url, true);
		xhr.onreadystatechange = function(){
			if(xhr.readyState == 4 && xhr.status == 200){     
		       var obj = eval('('+xhr.responseText+')'); 
			   alert(obj.m);         
	    	} 
		};
		xhr.send(fromData);   
         
	});
	
	$('#backBtn').click(function(){
		location.href = '/Home/Activity/main';
	});
});
</script>
</body>
</html>